<? include '../db_info.php'; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1">
<title>트러스 합주시간표</title>
<style type="text/css">
body { color: black; font-size: 10pt; font-family: 맑은고딕, 돋움;}
td { padding: 5px; }
a { color: black; text-decoration:none; }
a.emph { color: #FF4848; font-weight: bold; font-size: 14pt; }
</style>
</head>
<body>

	<div style="margin-left:-12px">
		<style>
		.timetable-mobile { width: 320px; height: 50px; }
		@media(min-width: 500px) { .timetable-mobile { width: 468px; height: 60px; } }
		@media(min-width: 800px) { .timetable-mobile { width: 728px; height: 90px; } }
		</style>
		<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
		<!-- timetable_mobile -->
		<ins class="adsbygoogle timetable-mobile"
		style="display:inline-block"
		data-ad-client="ca-pub-5628522240073835"
		data-ad-slot="3291943301"></ins>
		<script>
		(adsbygoogle = window.adsbygoogle || []).push({});
		</script>
	</div>

	<script language="JavaScript">
	var uAgent = navigator.userAgent.toLowerCase();
	document.write(uAgent+"<br />");
	</script>

	<a href="../index.php">PC version</a>

	<table width="100%">
		<tr><td colspan="2" align="left">합주팀 생성 / 사용방법</td></tr>
		<tr><td colspan="2" align="right">
			<form method="get" action="search.php">검색: 
				<!-- actual input box -->
				<input type="text" name="keyword" size="15" maxlength="20" />
				<input type="submit" value="찾기" />
			</form>
		</td></tr>
		<tr><td width="25%">시작 시간</td><td width="75%" align="center">월요일</td></tr>
		<?
		// data row saving variable
		$row = array();

		// regular timetable
		$regular = mysqli_query($connect, "SELECT * FROM timetable");
		// temporary timetable
		$temporary = mysqli_query($connect, "SELECT * FROM timetable_temp");
		// $clock is for time computation
		// +=50 means to add half an hour
		for ($clock = 900; $clock < 2400; $clock += 50) {
			// time representation start
			$temp1 = $clock / 100; // quotient means hour
			$temp2 = $clock % 100; // modulo means whether o'clock or half an hour
			$ampm = "오전"; // initial 
			if ($clock >= 1300) { $hour = (int)$temp1 - 12; $ampm = "오후"; } // 12-hour basis
			else $hour = (int)$temp1; // integer casting in order to remove floating point

			if ($temp2 == 0) { $minute = '00'; }
			else $minute = '30';
			?>
			<tr align="center">
				<!-- ex) 오전 9:00 -->
				<td align="right"><?=$ampm?> <?=$hour?>:<?=$minute?></td>
			<?
			// time representation end

			// get data from selected row
			$reg_row = mysqli_fetch_array($regular);
			$tmp_row = mysqli_fetch_array($temporary);
			
			if ($reg_row[1]) echo "<td>$reg_row[1]</td></tr>\n";
			elseif ($tmp_row[1]) echo "<td>$tmp_row[1]</td></tr>\n";
			else echo "<td></td></tr>\n";
		}
		?>
	</table>

</body>
</html>